from decimal import Decimal
from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field
from pydantic.alias_generators import to_camel
from typing import Optional
from module_admin.annotation.pydantic_annotation import as_query




class PlotModel(BaseModel):
    """
    种植地块表对应pydantic模型
    """
    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    plot_id: Optional[int] = Field(default=None, description='地块Id')
    plot_name: Optional[str] = Field(default=None, description='地块名称')
    plot_no: Optional[str] = Field(default=None, description='地块编号')
    plot_center_coordinates: Optional[bytes] = Field(default=None, description='地块坐标')
    plot_boundary: Optional[bytes] = Field(default=None, description='地块边界')
    year: Optional[int] = Field(default=None, description='数据年份')
    product_area_id: Optional[int] = Field(default=None, description='产区Id')
    product_area: Optional[str] = Field(default=None, description='产区')
    planter_id: Optional[int] = Field(default=None, description='种植主体Id')
    planter_name: Optional[str] = Field(default=None, description='种植主体')
    address: Optional[str] = Field(default=None, description='地址')
    plot_area_size: Optional[Decimal] = Field(default=None, description='地块面积')
    memo: Optional[str] = Field(default=None, description='备注')
    create_time: Optional[datetime] = Field(default=None, description='创建时间')
    create_by: Optional[str] = Field(default=None, description='创建人')
    update_time: Optional[datetime] = Field(default=None, description='更新时间')
    update_by: Optional[datetime] = Field(default=None, description='更新人')






class PlotQueryModel(PlotModel):
    """
    种植地块不分页查询模型
    """
    pass


@as_query
class PlotPageQueryModel(PlotQueryModel):
    """
    种植地块分页查询模型
    """

    page_num: int = Field(default=1, description='当前页码')
    page_size: int = Field(default=10, description='每页记录数')


class DeletePlotModel(BaseModel):
    """
    删除种植地块模型
    """

    model_config = ConfigDict(alias_generator=to_camel)

    plot_ids: str = Field(description='需要删除的地块Id')
